<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page errorPage="../errorPage.jsp" %>
<c:if test="${empty sessionScope.user}">
	<c:redirect url="../login.jsp" />
</c:if>
<c:if test="${sessionScope.user.getClass().name != 'accountManagement.Client' and sessionScope.user.getClass().name != 'accountManagement.Employee'}">
	<jsp:forward page="../errorPage.jsp">
		<jsp:param name="error" value="Access not permitted!" />
	</jsp:forward>
</c:if>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="ISO-8859-1">
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/template.css">
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/header.css">
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/footer.css">
		<title>Ricerca Corsa</title>
	</head>
	
	<body>
		<div id="body">
			<%@ include file="../header.jsp" %>
				
			<%@ include file="../menu.jsp" %>
				
			<div id="title">
				Ricerca Corsa
			</div>
		
			<div id="content">
				<form action="${pageContext.request.contextPath}/ServletSearchTransport" method="post">
					<div>
						<label>Id:</label>
						<input type="text" name="transportId">
					</div>
					<div>
						<label>Origine Corsa:</label>
						<input type="text" name="origin">
					</div>
					<div>
						<label>Destinazione Corsa:</label>
						<input type="text" name="destination">
					</div>
					<div>
						<input type="submit" value="Ricerca">
					</div>
				</form>
				
				<table>
					<thead>
						<tr>
							<th>Luogo Partenza</th>
							<th>Luogo Arrivo</th>
							<th>Dettagli</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${transportList}" var="transport">
							<tr>
								<td><c:out value="${transport.origin}"/></td>
								<td><c:out value="${transport.destination}"/></td>		
								<td>
									<a href="${pageContext.request.contextPath}/ServletViewTransportDetails?transportId=${transport.transportId}">
										<img src="${pageContext.request.contextPath}/img/details.gif" alt="Visualizza dettagli" title="Visualizza dettagli">
									</a>
								</td>
							</tr>
						</c:forEach>
						<c:if test="${transportList.size() == 0}" >
							<tr><td colspan="3">Nessun elemento rispetta i parametri della ricerca</td></tr>
						</c:if>
					</tbody>
				</table>
			</div>
			
			<%@ include file="../footer.jsp" %>
		</div>
	</body>
</html>